public class ControlPanel {
    private String password;
    private int wrongAttempts;
    private boolean isLocked;
    private static final int MAX_WRONG_ATTEMPTS = 3;
    private static final long LOCK_DURATION = 120000; // 锁定时间120秒

    public ControlPanel(String password) {
        this.password = password;
        this.wrongAttempts = 0;
        this.isLocked = false;
    }

    public void inputPassword(char[] input) {
        if (isLocked) {
            System.out.println("Control panel is locked.");
            return;
        }

        if (input.length == password.length() && checkPassword(input)) {
            System.out.println("Password correct, entering function selection.");
            // 进入系统功能选择状态
        } else {
            wrongAttempts++;
            if (wrongAttempts >= MAX_WRONG_ATTEMPTS) {
                System.out.println("Control panel locked due to too many wrong attempts.");
                isLocked = true;
                // 锁定控制面板
            }
        }
    }

    private boolean checkPassword(char[] input) {
        return new String(input).equals(password);
    }

    public void unlockAfterDuration() {
        if (isLocked) {
            // 假设此方法在锁定时间后被调用
            try {
                Thread.sleep(LOCK_DURATION);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            isLocked = false;
            wrongAttempts = 0;
            System.out.println("Control panel unlocked after duration.");
        }
    }

    public static void main(String[] args) {
        ControlPanel panel = new ControlPanel("1234");
        char[] input1 = {'1', '2', '3', '4'};
        char[] input2 = {'1', '2', '3'};
        char[] input3 = {'5', '6', '7', '8'};
        char[] correctInput = {'1', '2', '3', '4'};

        panel.inputPassword(input1); // 错误密码
        panel.inputPassword(input2); // 错误密码
        panel.inputPassword(input3); // 错误密码，锁定面板
        panel.unlockAfterDuration(); // 解锁面板
        panel.inputPassword(correctInput); // 正确密码
    }
}